﻿
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "IWidget.h"
#include "Vector3d.h"
#include "PickNodeReferenceOption.h"
#include "IDockablePickFilterWidget.h" // 不是必须的，为了UI层方便创建PickFilterDlg

#include "QDialog"
#include "BaseTreeDlg.h"
#include "PickSnapModule.h"

class QTreeWidgetItem;

/// 本文件是界面实现的辅助类，不包含GDMP API的演示内容
namespace gcmp
{
    class IDock;
    class UniIdentity;
    class ISnapContext;
    class ISnapSettings;
    class IPickPointActionConfig;
    struct PickPointExchangeData;
}

namespace Sample
{
    enum class SnapMethod;

    // 捕捉过滤浮动工具栏
    class SnapFilterDlg : public BaseTreeDlg
    {
        Q_OBJECT

    public:
        SnapFilterDlg(QWidget *parent = nullptr);
        ~SnapFilterDlg();

        // 根据捕捉过滤UI设置捕捉API接口
        void SetSnapContext(gcmp::ISnapContext* pSnapContext);
        void SetSnapSettings(gcmp::ISnapSettings* pSnapSettings);
        
        static SnapFilterDlg* Get();
        static SnapFilterDlg* Create();

        void ShowDock() override;
        void HideDock() override;

        void InitQTree();

        // 设置捕捉API接口，并刷新可用的选项
        void SetSnapMethod(SnapMethod snapMethod);

    private:
        std::map<std::wstring, std::function<void(gcmp::ISnapContext*, bool)>> m_snapContextMap;
        std::map<std::wstring, std::function<void(gcmp::ISnapSettings*, bool)>> m_snapSettingsMap;

        QTreeWidgetItem* m_snapContextNodeGroup;
        QTreeWidgetItem* m_snapSettingsNodeGroup;
    };
}

